package com.aletto.general_store.ui.activities;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.aletto.general_store.R;
import com.aletto.general_store.utils.ToastUtils;
import com.aletto.general_store.utils.XHelper;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class AboutUsActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about_us);

        XHelper.initTitle(this, R.string.title_about_us);

        TextView tv_version_code = findViewById(R.id.tv_version_code);
        tv_version_code.setText("0xBuy " + getVersionName());

        View button_update = findViewById(R.id.button_update);
        button_update.setOnClickListener(v -> ToastUtils.makeText(R.string.news_version));
    }

    public String getVersionName(){

        try {
            PackageManager pm = getPackageManager();
            PackageInfo packageInfo = pm.getPackageInfo(getPackageName(), 0);
            return packageInfo.versionName;
        } catch (PackageManager.NameNotFoundException e) {

            return "1.0.0";
        }
    }

}
